package com.es;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;

public class P {

	public static void main(String[] args) throws MQClientException, InterruptedException, RemotingException, MQBrokerException {
		DefaultMQProducer producer = new DefaultMQProducer("rmq-group");
		 producer.setNamesrvAddr("192.168.0.53:9876");
		producer.setInstanceName("producer");
		producer.start();

		Thread.sleep(5000); //每5秒发送一次MQ
		Message msg = new Message("TopicA-test",
					"TagA"," Hello RocketMQ ,QuickStart".getBytes());
		SendResult sendResult = producer.send(msg);
		System.out.println(sendResult);
		producer.shutdown();
	}

}
